{template 'header', 'member'}
<script type="text/javascript">menuChanger('menu_web');</script>
<div class="menus">
	<table cellpadding="0" cellspacing="0">
		<tr>
			<td class="tab" id="Tab0"><a href="home.php"><span>网站设置</span></a></td>
			<td class="tab_nav">&nbsp;</td>
			<td class="tab" id="Tab1"><a href="style.php"><span>模板设置</span></a></td>
			<td class="tab_nav">&nbsp;</td>
			<td class="tab" id="Tab2"><a href="{SITE_URL}index.php?homepage={$_username}&update=1" target="homepage"><span>更新主页</span></a></td>
		</tr>
	</table>
</div>
{if $action == 'buy'}
<form method="post" action="style.php" onsubmit="return check();">
	<input type="hidden" name="action" value="{$action}"/>
	<input type="hidden" name="itemid" value="{$itemid}"/>
	<table class="data-form">
		<th width="90">模板预览：</th>
		<td class="tr"><a href="{SITE_URL}index.php?homepage={$_username}&preview={$itemid}" target="_blank"><img src="{$thumb}" style="border:#EEEEEE 2px solid;padding:5px;margin:0 0 10px 0;" alt="预览"/></a></td>
		</tr>
		<tr>
			<th width="90"><span class="cred">*</span> 购买时长：</th>
			<td class="tr f_gray">
				<select name="month" id="month" onchange="CA();">
					{loop $months $m}
						<option value="{$m}">{$m}月</option>{/loop}
				</select>
				(注:按30天/月计算)
			</td>
		</tr>
		<tr>
			<th width="90">模板价格：</th>
			<td class="tr"><strong class="cred">{$fee}{$unit}/月</strong></td>
		</tr>
		<tr>
			<th width="90">应付总价：</th>
			<td class="tr cred f_b"><span id="payment">{$fee}</span>{$unit}</td>
		</tr>
		{if $currency == 'money'}
			<tr>
				<th width="90">{$DT[money_name]}余额：</th>
				<td class="tr"><span class="f_blue f_b">{$_money}{$unit}</span> <a href="{$MODULE[2][linkurl]}charge.php?action=pay" target="_blank" class="t">[充值]</a></td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span> 支付密码：</th>
				<td class="tr">{template 'password', 'chip'}</td>
			</tr>
			{else}
			<tr>
				<th width="90">{$DT[credit_name]}余额：</th>
				<td class="tr"><span class="f_blue f_b">{$_credit}{$unit}</span> <a href="{$MODULE[2][linkurl]}credit.php?action=buy" target="_blank" class="t">[购买]</a></td>
			</tr>
		{/if}
		<tr>
			<th width="90"></th>
			<td class="tr" height="50"><input type="submit" name="submit" value=" 确 定 " class="btn"/></td>
		</tr>
	</table>
</form>
<script type="text/javascript">
	function CA() {
		Dd('payment').innerHTML = {$fee}*
		Dd('month').value;
	}
	function check() {
		{if $currency == 'money'}
			if ({$fee}*
			Dd('month').value > {$_money})
			{
				alert('帐户余额不足，请先充值');
				return false;
			}
			if ( Dd('password').value.length < 6 ) {
				alert('请填写支付密码');
				Dd('password').focus();
				return false;
			}
			{else}
			if ({$fee}*
			Dd('month').value > {$_credit})
			{
				alert('您的{$DT[credit_name]}不足，请先购买');
				return false;
			}
		{/if}
		return confirm('确定要购买' + Dd('month').value + '月吗？');
	}
</script>
	{else}
<form action="style.php">
	<input type="hidden" name="all" id="all" value="{$all}"/>

	<div class="tt">
		&nbsp;{$fields_select}&nbsp;
		<input type="text" size="12" name="kw" value="{$kw}" title="关键词"/>&nbsp;
		{$type_select}&nbsp;
		价格：<input type="text" size="3" name="minfee" value="<?php echo $minfee;?>"/>~
		<input type="text" size="3" name="maxfee" value="<?php echo $maxfee;?>"/>&nbsp;
		<select name="currency">
			<option value="">单位</option>
			<option value="money"{if $currency == 'money'} selected{/if}>{$DT[money_name]}</option>
			<option value="credit"{if $currency == 'credit'} selected{/if}>{$DT[credit_name]}</option>
			<option value="free"{if $currency == 'free'} selected{/if}>免费</option>
		</select>&nbsp;
		{$order_select}&nbsp;
		<input type="submit" value=" 搜 索 " class="btn"/>
		<input type="button" value=" 重 置 " class="btn" onclick="window.location='style.php';"/>
		{if $all}
			<input type="submit" value=" 显示可用 " class="btn" onclick="Dd('all').value=0;"/>
			{else}
			<input type="submit" value=" 显示全部 " class="btn" onclick="Dd('all').value=1;"/>
		{/if}
	</div>
</form>
<table cellpadding="10" cellspacing="10" width="100%" bgcolor="#FFFFFF">
	{if $lists}
		{loop $lists $k $v}
			{if $k%3==0}
			<tr>{/if}
			<td width="33%" valign="top">
				<table cellpadding="2" cellspacing="2" width="220" align="center"{if $c[skin] == $v[skin]} bgcolor="#E7ECFF"{/if}>
					<tr>
						<td><a href="{SITE_URL}index.php?homepage={$_username}&preview={$v[itemid]}" target="_blank"><img src="{$v[thumb]}" style="border:#EEEEEE 2px solid;padding:5px;margin:0 0 10px 0;" title="点击预览"/></a></td>
					</tr>
					<tr align="center">
						<td>{$v[title]}</td>
					</tr>
					<tr align="center">
						<td>
							{if $c[skin] == $v[skin]}
								<a href="{SITE_URL}index.php?homepage={$_username}&update=1" target="_blank" class="t">我的主页</a> <span class="cred">[{if $havedays}{$havedays}天剩余{else}使用中{/if}]</span>
								{else}
								{if $v[fee]}<a href="?action=buy&itemid={$v[itemid]}" class="t">购买</a>{else}<a href="?itemid={$v[itemid]}" class="t"{if $havedays} onclick="return confirm('确定要启用此模板吗？如果之前购买过模板，付费模板的有效期将被清空');"{/if}>启用</a>{/if}&nbsp;|&nbsp;<a
									href="{SITE_URL}index.php?homepage={$_username}&preview={$v[itemid]}" target="_blank" class="t">预览</a>
							{/if}
						</td>
					</tr>
				</table>
			</td>
			{if $k%3==2}</tr>{/if}
		{/loop}
		{else}
		<tr>
			<td class="cred">提示信息：未找到相关模板</td>
		</tr>
	{/if}
</table>
<div class="pages">{$pages}</div>
{/if}
<script type="text/javascript">s('style');m('Tab1');</script>
{template 'footer', 'member'}